package com.example.sys.service.impl;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sys.entity.DictType;
import com.example.sys.mapper.DictTypeMapper;
import com.example.sys.service.DictTypeService;
import com.example.sys.vo.DictTypeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 字典类型表 服务实现类
 * </p>
 *
 * @author anan
 * @since 2019-06-20
 */
@Service
public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements DictTypeService {

    @Autowired
    private DictTypeMapper dictTypeMapper;

    @Override
    public IPage<DictType> selectPage(DictTypeVo dictTypeVo) {
        IPage<DictType> iPage = new Page<>(dictTypeVo.getPage(), dictTypeVo.getLimit());
        QueryWrapper<DictType> wrapper = new QueryWrapper<>();
        if (!StrUtil.hasEmpty(dictTypeVo.getDictName()))
            wrapper.like("dict_name", dictTypeVo.getDictName());
        if (!StrUtil.hasEmpty(dictTypeVo.getDictType()))
            wrapper.like("dict_type", dictTypeVo.getDictType());
        if (!StrUtil.hasEmpty(dictTypeVo.getStatus()))
            wrapper.like("status", dictTypeVo.getStatus());
        return dictTypeMapper.selectPage(iPage, wrapper);
    }
}
